##
# Copyright (c) 2012, Ken Anderson, Brent Mucci
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without modification, 
# are permitted provided that the following conditions are met:
# 
# 1. Redistributions of source code must retain the above copyright notice, 
#    this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice, 
#    this list of conditions and the following disclaimer in the documentation 
#    and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
##

# Compiler settings
set(CMAKE_BUILD_TYPE Debug)

set(mediaCL_HEADERS mcl_bitmap.h mcl_image_resize.h mcl_image_resize_bilinear.h mcl_image_resize_bilinearCL.h mcl_cl_image.h mcl_visualizer.h mcl_image.h mcl_common.h mcl_timer.h mcl_box_filter.h mcl_h264_decoder.h)
set(mediaCL_SOURCE mcl_bitmap.cpp mcl_image_resize_bilinear.cpp mcl_resize_image_bilinearCL.cpp mcl_bitmap_resample.cpp mcl_cl_image.cpp mcl_visualizer.cpp mcl_image.cpp mcl_bilinear_sampling.cl mcl_h264_decoder.cpp)
set(H264_HEADERS mcl_bitstream_buffer.hpp mcl_nal.hpp mcl_nal_unit_header_mvc_extension.hpp mcl_params_rbsp.hpp mcl_bitstream_decoder.hpp mcl_nal_reader.hpp)
set(H264_SOURCE mcl_bitstream_buffer.cpp mcl_nal.cpp mcl_nal_unit_header_mvc_extension.cpp mcl_params_rbsp.cpp mcl_bitstream_decoder.cpp mcl_nal_reader.cpp)

# Library
include_directories( "../../h264/src" ${SFML_INCLUDE_DIR} ${OPENCL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} )
set(LIBS ${SFML_LIBRARIES} ${OPENCL_LIBRARIES} ${OPENGL_LIBRARY}) #Pay attention to order
add_library (mediaClLib ${mediaCL_SOURCE} ${mediaCL_HEADERS})

# MCL H264 Library
add_library (H264ClLib ${H264_HEADERS} ${H264_SOURCE})

# Test MCL H264 Library functions
add_executable (H264ClLib-test mcl_h624-test.cpp)
target_link_libraries(H264ClLib-test H264ClLib mediaClLib)

# Test Visualizer
include_directories( . ${SFML_INCLUDE_DIR} ${OPENCL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} )
add_executable (play_bmp-test play_bmp-test.cpp)
target_link_libraries(play_bmp-test mediaClLib ${LIBS})

# Test H264
include_directories( . "../../h264/src" ${SFML_INCLUDE_DIR} ${OPENCL_INCLUDE_DIRS} ${OPENGL_INCLUDE_DIR} )
add_executable (play_h264-test play_h264-test.cpp)
target_link_libraries(play_h264-test mediaClLib h264lib ${LIBS})

# Copy extra files
configure_file( mcl_bilinear_sampling.cl ${CMAKE_CURRENT_BINARY_DIR}/mcl_bilinear_sampling.cl COPYONLY)

# Create sub-folder
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
SET_PROPERTY(TARGET play_h264-test      PROPERTY FOLDER "media-cl")
SET_PROPERTY(TARGET play_bmp-test       PROPERTY FOLDER "media-cl")
SET_PROPERTY(TARGET mediaClLib          PROPERTY FOLDER "media-cl")
SET_PROPERTY(TARGET H264ClLib		PROPERTY FOLDER "media-cl")
SET_PROPERTY(TARGET H264ClLib-test	PROPERTY FOLDER "media-cl")

